#include "main.h"

void startSecretEditor(); // Fires up tAhe item, weapon and armor editor

void intro();

void createPlayer();

void intro()
{
	int iStr; // Strength - for attack and fighters
	int iDex; // Dexterity - for armor, AP and thiefs
	int iCon; // Constitution - for health and fighters
	int iInt; // Intelligence - for magic
	int iPer; // Perception - for AP, magic and thiefs

	// get name, then roll for stats, min of 8, max of 18
	// double check before exit
	bool bDone = false;

	while(!bDone)
	{
		do // get name
		{
			gBool = true;
			px.getS(gString, "What is your name hero?");
			px.text("Welcome ",0);
			px.text(gString);
			px.getS(gString, "Is that right y/n > ");

			if(gString == "y" || gString == "Y")
				gBool = false;
		}
		while(gBool);

		do // get stats
		{
			gBool = true;

			px.nl(30);

			px.rng(iStr);
			px.rng(iDex);
			px.rng(iCon);
			px.rng(iInt);
			px.rng(iPer);
			if(iStr<8) iStr=8;
			if(iDex<8) iDex=8;
			if(iCon<8) iCon=8;
			if(iInt<8) iInt=8;
			if(iPer<8) iPer=8;
			if(iStr>18) iStr=18;
			if(iDex>18) iDex=18;
			if(iCon>18) iCon=18;
			if(iInt>18) iInt=18;
			if(iPer>18) iPer=18;
			px.text("Strength: ",0);
			px.number(iStr);
			px.text("Dexterity: ",0);
			px.number(iDex);
			px.text("Constitution: ", 0);
			px.number(iCon);
			px.text("Intelliegence: ", 0);
			px.number(iInt);
			px.text("Perception: ", 0);
			px.number(iPer);

			px.text("r.\t(R)eroll stats");
			px.text("k.\t(K)eep stats");
			px.text("h.\t(H)elp");
			px.text("x.\tE(x)it");

			gString.clear();
			px.getS(gString, "What is your decision hero > ");

			if(gString=="r"||gString=="R")
				gInt = 1;
			else if(gString=="k"||gString=="K")
				gInt = 2;
			else if(gString=="h"||gString=="H")
				gInt = 3;
			else if(gString=="x"||gString=="X")
				gInt = 10;
			else
				gInt = 0; // defaults to error

			switch(gInt)
			{
			case 1:
				break;

			case 2:
				px.getS(gString, "Are you sure that you want to keep these stats? y/n > ");
				if(gString == "y" || gString == "Y")
				{
					gBool = false;
					bDone = true;
				}
				break;

			case 3:
				px.text("Strength determines how hard you can swing and how much you can pick up.");
				px.text("Dexterity determines how quick you are with your hands and feet.");
				px.text("Constitution determines how healthy you are and your endurance.");
				px.text("Intelligence determines how much you can use your mind power.");
				px.text("Perception determines how aware you are of yourself and others.");
				px.pause();
				break;

			case 10:
				px.getS(gString, "Are you sure you want to leave town? It's cold (y/n) > ");
				if(gString == "y" || gString == "Y")
				{
					px.pause("Goodbye. We will miss you.\nPress enter to continue...");
					gBool = false;
					bDone = true;
					gDone = true;
				}
				break;

			default:
				px.pause("Please put in a valid option.\nPress enter to continue...");
				break;
			}
		}
		while(gBool);
	}

	// set player stats here

	gIsCharacterMade = true;
}

int main()
{
	while(!gDone)
	{
		startSecretEditor();
		if(gDone)// if you want to leave the editor
			break;

		// Check for save games before doing this
		if(gNewGame)
		{
			intro();
			gInTown = true;
		}
		// else load save game
		// part of the town main point of the game
		interpret();

		// autosave, then ask if you want to leave.

		px.getS(gString, "Are you sure that you want to leave y/n > ");
		if(gString == "y" || gString == "Y")
		{
			gDone = true;
			break;
		}

	}
	return 0;
}
